﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.Caching;

public class CacheExtensionMethod
{
    public static void Clear(this Cache x)
    {
        List<string> cacheKeys = new List<string>();
        System.Collections.IDictionaryEnumerator cacheEnum
            = x.GetEnumerator();
        while (cacheEnum.MoveNext())
        {
            cacheKeys.Add(cacheEnum.Key.ToString());
        }

        foreach (string cacheKey in cacheKeys)
        {
            x.Remove(cacheKey);
        }
    }
}